package com.weipeep.sys.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.google.common.collect.Maps;
import org.springframework.stereotype.Service;

import com.weipeep.sys.dao.ResetPasswordDao;
import com.weipeep.sys.domain.ResetPasswordDO;
import com.weipeep.sys.service.ResetPasswordService;
import com.weipeep.common.base.CoreServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 
 * <pre>
 * 重置密码表
 * </pre>
 * <small> 2018-07-14 14:10:43 | wangyun</small>
 */
@Service
public class ResetPasswordServiceImpl extends CoreServiceImpl<ResetPasswordDao, ResetPasswordDO> implements ResetPasswordService {
    @Resource
    private ResetPasswordDao resetPasswordDao;

    @Override
    @Transactional
    public void resetPasswordEmail(ResetPasswordDO resetPasswordDO) {
        Wrapper<ResetPasswordDO> resetPasswordDOWrapper = new EntityWrapper<ResetPasswordDO>();
        resetPasswordDOWrapper.eq("user_id",resetPasswordDO.getUserId());
        resetPasswordDOWrapper.eq("valid",1);
        ResetPasswordDO abandon = new  ResetPasswordDO();
        abandon.setValid(0);
        resetPasswordDao.update(abandon,resetPasswordDOWrapper);
        resetPasswordDao.insert(resetPasswordDO);
    }
}
